<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />





  <link rel="alternate" href="/atom.xml" title="Fenlon's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="Do Something">
<meta property="og:type" content="website">
<meta property="og:title" content="Fenlon&#39;s Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Fenlon&#39;s Blog">
<meta property="og:description" content="Do Something">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Fenlon&#39;s Blog">
<meta name="twitter:description" content="Do Something">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"hide","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/"/>





  <title>Fenlon's Blog</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  















  
  
    
  

  <div class="container sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Fenlon's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/03/27/java/java-base/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/27/java/java-base/" itemprop="url">java基础</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-27T16:33:30+08:00">
                2018-03-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index">
                    <span itemprop="name">java</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>本篇主要记录Java的一些基本知识</p>
<h3 id="List和Set的区别"><a href="#List和Set的区别" class="headerlink" title="List和Set的区别"></a><a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html" target="_blank" rel="external">List</a>和<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Set.html" target="_blank" rel="external">Set</a>的区别</h3>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/01/04/network/tcpdump抓包解释tcp三次握手四次挥手/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/01/04/network/tcpdump抓包解释tcp三次握手四次挥手/" itemprop="url">tcpdump抓包tcp三次握手四次挥手</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-01-04T15:14:21+08:00">
                2018-01-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/network/" itemprop="url" rel="index">
                    <span itemprop="name">network</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/network/socket/" itemprop="url" rel="index">
                    <span itemprop="name">socket</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近项目遇到了经典的<a href="https://www.google.co.jp/search?q=tcp+40ms+delay&amp;oq=tcp+40ms+delay&amp;aqs=chrome..69i57j69i60j69i59.240j0j9&amp;sourceid=chrome&amp;ie=UTF-8" target="_blank" rel="external">tcp 40ms delay</a>,tcpdump抓包显示当连续两次调用write操作时，第二次会等第一次接收到ack后才能发送给server端。</p>
<p>今天使用<code>tcpdump</code>抓包验证一下<code>tcp</code>连接的三次握手和四次挥手</p>
<h3 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h3><p>可能还需要进一步论证<br>TCP三次握手四次挥手可能描述上有些问题，下面实验表明可能存在着4次握手，三次挥手的情况，根据系统的不同（可能是网络参数优化造成的，最可能的是tcp_delayed_ack造成的)。 至于经典的<code>TCP 40ms delay</code>问题，是因为client端使用了<a href="https://en.wikipedia.org/wiki/Nagle&#39;s_algorithm" target="_blank" rel="external"><code>Nagle&#39;s_algorithm</code></a>优化网络，server端使用了<a href="https://en.wikipedia.org/wiki/TCP_delayed_acknowledgment" target="_blank" rel="external"><code>TCP DELAYED ACK</code></a>优化网络。具体原因和解决方案，可以看书籍<a href="https://book.douban.com/subject/1500149/" target="_blank" rel="external"><code>UNIX网络编程</code></a>第七章中关于TCP_NODELAY套接字的部分。</p>
<h3 id="测试一"><a href="#测试一" class="headerlink" title="测试一"></a>测试一</h3><ul>
<li>环境<ul>
<li>client server 同台机器</li>
<li>MacOS 10.13.1</li>
<li>原理使用<a href="https://www.google.co.jp/search?q=linux+nc&amp;oq=linux+nc&amp;aqs=chrome..69i57j0j69i61l2j69i59j0.357j0j9&amp;sourceid=chrome&amp;ie=UTF-8" target="_blank" rel="external"><code>nc</code></a>命令,模拟Server端和Client端</li>
</ul>
</li>
<li><p>执行</p>
<ul>
<li>1：终端执行 nc -l 9999 (模拟Server)</li>
<li>2：终端执行 tcpdump ‘port 9999’ -i lo -S (注意要找到ip为127.0.0.1对应的网卡)</li>
<li><p>3：终端执行nc localhost 9999 (模拟Client)</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">client向server发送SYN和seq</div><div class="line">15:55:29.810229 IP localhost.56498 &gt; localhost.distinct: Flags 		[S], 	seq 101048875, win 65535, options [mss 16344,nop,wscale 		5,nop,nop,TS val 726072074 ecr 0,sackOK,eol], length 0</div><div class="line"></div><div class="line">server向client发送SYN+ACK和seq</div><div class="line">15:55:29.810325 IP localhost.distinct &gt; localhost.56498: Flags 		[S.], seq 841661562, ack 101048876, win 65535, options [mss 		16344,nop,wscale 5,nop,nop,TS val 726072074 ecr 		726072074,sackOK,eol], length 0</div><div class="line"></div><div class="line">client向server发送ACK</div><div class="line">15:55:29.810341 IP localhost.56498 &gt; localhost.distinct: Flags 		[.], 	ack 841661563, win 12759, options [nop,nop,TS val 		726072074 ecr 	726072074], length 0</div><div class="line">	</div><div class="line">server向Client发送ACK</div><div class="line">15:55:29.810352 IP localhost.distinct &gt; localhost.56498: Flags 		[.], 	ack 101048876, win 12759, options [nop,nop,TS val 		726072074 ecr 	726072074], length 0</div></pre></td></tr></table></figure>
<p>  上面的抓包显示之间共有四次握手，其中最后一次server向client发送ack，在很多系统中是没有的，因为在第二步server已经向client发送了ack。（原本以为Macos没有使用tcp_delayed_ack,最后发现其实是使用了，不了解为什么会ack两次）。</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">mac 查询是否使用了tcp_delayed_ack</div><div class="line">终端执行：sudo sysctl -a | grep net.inet.tcp.delayed_ack</div><div class="line">net.inet.tcp.delayed_ack: 3</div><div class="line"></div><div class="line">delayed_ack=0 responds after every packet (OFF)</div><div class="line">delayed_ack=1 always employs delayed ack, 6 packets can get 1 		ack</div><div class="line">delayed_ack=2 immediate ack after 2nd packet, 2 packets per ack 		(Compatibility Mode)</div><div class="line">delayed_ack=3 should auto detect when to employ delayed ack, 4 		packets per ack. (DEFAULT recommended)</div></pre></td></tr></table></figure>
</li>
<li><p>4：client终端断开连接(Ctrl+C)</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">client向server发送FIN和seq</div><div class="line"></div><div class="line">15:41:51.867597 IP localhost.54819 &gt; localhost.distinct: Flags [F.], seq 3758577129, ack 382273321, win 12759, options [nop,nop,TS val 		725256837 ecr 725129655], length 0</div><div class="line">              		</div><div class="line">      server向client发送ACK</div><div class="line">      15:41:51.867652 IP localhost.distinct &gt; localhost.54819: Flags [.], ack 3758577130, win 12759, options [nop,nop,TS val 725256837 ecr 		725256837], length 0</div><div class="line">              		</div><div class="line">      server向client发送FIN+ACK（其实ACK上一步已经发送过了，有的系统只会发送一次，可能是网络优化）</div><div class="line">      15:41:51.867688 IP localhost.distinct &gt; localhost.54819: Flags [F.], seq 382273321, ack 3758577130, win 12759, options [nop,nop,TS val 		725256837 ecr 725256837], length 0</div><div class="line">              		</div><div class="line">      client向server发送ACK</div><div class="line">      15:41:51.867724 IP localhost.54819 &gt; localhost.distinct: Flags [.], ack 382273322, win 12759, options [nop,nop,TS val 725256837 ecr 		725256837], length 0</div></pre></td></tr></table></figure>
<p>  上面的四次握手和书中写的基本一致，但是在有的系统中第二步和第三步是作为一步的，即<code>server向client发送FIN+ACK</code>,可能和TCP_DELAYED_ACK有关系。</p>
</li>
</ul>
</li>
</ul>
<h3 id="测试二"><a href="#测试二" class="headerlink" title="测试二"></a>测试二</h3><ul>
<li><p>环境</p>
<ul>
<li>client server 同台机器</li>
<li>centos 7.2.1511</li>
</ul>
</li>
<li><p>执行</p>
<ul>
<li>1：终端执行 nc -l 9999 (模拟Server)</li>
<li>2：终端执行 tcpdump ‘port 9999’ -i lo -S (注意要找到ip为127.0.0.1对应的网卡)</li>
<li><p>3：终端执行nc localhost 9999 (模拟Client)</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">client向server发送SYN和seq</div><div class="line">15:47:53.855406 IP localhost.47686 &gt; localhost.distinct: Flags 		[S], seq 3848885127, win 43690, options [mss 65495,sackOK,TS val 		3471073701 ecr 0,nop,wscale 7], length 0</div><div class="line"></div><div class="line">server向client发送SYN+ACK和seq</div><div class="line">15:07:31.131256 IP localhost.distinct &gt; localhost.47686: Flags 		[S.], seq 2504659360, ack 3848885128, win 43690, options [mss 		65495,sackOK,TS val 3471073701 ecr 3471073701,nop,wscale 7], 		length 0</div><div class="line"></div><div class="line">client向server发送ACK</div><div class="line">15:47:53.855430 IP localhost.47686 &gt; localhost.distinct: Flags 		[.], ack 2504659361, win 342, options [nop,nop,TS val 3471073701 		ecr 3471073701], length 0</div></pre></td></tr></table></figure>
<p>  上面的抓包显示之间共有三次握手，区别上个测试，Server将SYN+ACK发送后，不会再重复发送ACK</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">mac 查询是否使用了tcp_delayed_ack</div><div class="line">终端执行：sudo sysctl -a | grep net.inet.tcp.delayed_ack</div><div class="line">net.inet.tcp.delayed_ack: 3</div><div class="line"></div><div class="line">delayed_ack=0 responds after every packet (OFF)</div><div class="line">delayed_ack=1 always employs delayed ack, 6 packets can get 1 		ack</div><div class="line">delayed_ack=2 immediate ack after 2nd packet, 2 packets per ack 		(Compatibility Mode)</div><div class="line">delayed_ack=3 should auto detect when to employ delayed ack, 4 		packets per ack. (DEFAULT recommended)</div></pre></td></tr></table></figure>
</li>
<li><p>4：client终端断开连接(Ctrl+C)</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">client向server发送FIN和seq</div><div class="line">17:12:27.911405 IP localhost.47688 &gt; localhost.distinct: Flags 		[F.], seq 1376424971, ack 2766855978, win 342, options 		[nop,nop,TS val 3476147757 ecr 3476140792], length 0</div><div class="line">                </div><div class="line">server向client发送FIN+ACK</div><div class="line">17:12:27.911484 IP localhost.distinct &gt; localhost.47688: Flags 		[F.], seq 2766855978, ack 1376424972, win 342, options 		[nop,nop,TS val 3476147757 ecr 3476147757], length 0</div><div class="line">                		</div><div class="line">client向server发送ACK</div><div class="line">17:12:27.911493 IP localhost.47688 &gt; localhost.distinct: Flags 		[.], ack 2766855979, win 342, options [nop,nop,TS val 3476147757 		ecr 3476147757], length 0</div></pre></td></tr></table></figure>
<p>  上面的三次挥手和理论上的四次挥手又不太一致，本系统中将ACK+FIN一次发送,可能和TCP_DELAYED_ACK有关系。</p>
</li>
</ul>
</li>
</ul>
<h3 id="测试三"><a href="#测试三" class="headerlink" title="测试三"></a>测试三</h3><ul>
<li><p>环境</p>
<ul>
<li>clien server 不同机器</li>
<li>client macOS</li>
<li>server centos</li>
</ul>
</li>
<li><p>结论<br>  基本上和上面一样，建立连接三次握手，中断连接三次挥手</p>
</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/06/13/java-log/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/06/13/java-log/" itemprop="url">java日志输出</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-13T15:37:30+08:00">
                2017-06-13
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index">
                    <span itemprop="name">java</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/日志-log/" itemprop="url" rel="index">
                    <span itemprop="name">日志(log)</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>在<code>java</code>开发中遇到了很多有关Log的依赖，如<code>log4j</code>,<code>commons-logging</code>,<code>slfj</code>，<code>logback</code>，以及很多相关的依赖。一直没搞明白之间是怎么个关系,今天大致看了一下，总结一下。</p>
<h4 id="提供日志解决方案"><a href="#提供日志解决方案" class="headerlink" title="提供日志解决方案"></a>提供日志解决方案</h4><ul>
<li>log4j</li>
<li>jdk-logging</li>
<li>logback</li>
</ul>
<h4 id="提供日志接口-门面"><a href="#提供日志接口-门面" class="headerlink" title="提供日志接口/门面"></a>提供日志接口/门面</h4><ul>
<li>common-logging<ul>
<li>提供日志接口，用户选择第三方日子组件作为具体实现，通过动态查找机制找到真正的日志库，不适合OSGI组件开发</li>
</ul>
</li>
<li>slf4j<ul>
<li>即简单日志门面（Simple Logging Facade for Java），不是具体的日志解决方案，它只服务于各种各样的日志系统</li>
</ul>
</li>
</ul>
<h4 id="SLF4J相关桥接"><a href="#SLF4J相关桥接" class="headerlink" title="SLF4J相关桥接"></a>SLF4J相关桥接</h4><p><img src="images/slf4j.png" alt="slf4j相关桥接"></p>
<h4 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h4><p><a href="http://blog.csdn.net/yycdaizi/article/details/8276265" target="_blank" rel="external">参考</a></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/06/07/linux-monitor-top/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/06/07/linux-monitor-top/" itemprop="url">Linux 系统常用监控 - Top命令</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-07T20:22:00+08:00">
                2017-06-07
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/linux/" itemprop="url" rel="index">
                    <span itemprop="name">linux</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="Top-进程监控"><a href="#Top-进程监控" class="headerlink" title="Top - 进程监控"></a>Top - 进程监控</h3><p>Linux环境下Top命令是一个性能监控程序，很多Linux或者类Unix系统环境都会自带这个命令。Top命令可以显示CPU使用率，内存使用率，交换内存使用率，<br>高速缓存使用大小，缓冲区使用大小，进程PID等系统各项指标。</p>
<h4 id="基本介绍"><a href="#基本介绍" class="headerlink" title="基本介绍"></a>基本介绍</h4><pre><code><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">命令格式</div><div class="line">    top [参数]</div><div class="line">命令表达式</div><div class="line">    -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols]</div><div class="line">命令参数</div><div class="line">    -h | -v 帮助/版本信息</div><div class="line">    -b 批处理</div><div class="line">    -c 显示完整的命令</div><div class="line">    -d 延迟时间（屏幕数据更新间隔时间,单位秒）</div><div class="line">    -H 线程模式</div><div class="line">    -i 忽略闲置（idle）或无用的进程</div><div class="line">    -n 更新次数</div><div class="line">    -o 指定排序字段（字段前可以用-/+表示排序顺序,如top -o +VIRT)</div><div class="line">    -O 显示所有的可用字段（针对-o命令）</div><div class="line">    -p 监控的PID</div><div class="line">    -s 保密模式</div><div class="line">    -S 累积模式</div><div class="line">    -u 指定用户</div><div class="line">    -w 指定输出宽度</div></pre></td></tr></table></figure>
</code></pre><h4 id="参数含义"><a href="#参数含义" class="headerlink" title="参数含义"></a>参数含义</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">top - 21:33:30 up 83 days,  6:06,  2 users,  load average: 0.06, 0.06, 0.05</div><div class="line">Tasks: 132 total,   1 running, 131 sleeping,   0 stopped,   0 zombie</div><div class="line">%Cpu(s):  0.6 us,  0.2 sy,  0.0 ni, 98.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.3 st</div><div class="line">KiB Mem :  8010968 total,   750528 free,  4151872 used,  3108568 buff/cache</div><div class="line">KiB Swap:  8388604 total,  8251808 free,   136796 used.  3582444 avail Mem </div><div class="line"></div><div class="line">  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                       </div><div class="line"> 3199 root      20   0 2767124 103260   6692 S   2.3  1.3  47:16.85 java                                                                                                                                          </div><div class="line">26803 deploy    20   0 10.982g 2.835g 296936 S   1.3 37.1 628:37.92 java                                                                                                                                          </div><div class="line">   13 root      20   0       0      0      0 S   0.3  0.0 371:21.46 rcu_sched                                                                                                                                     </div><div class="line"> 2906 root      20   0  952572  34588   9532 S   0.3  0.4  70:32.27 hickwall                                                                                                                                      </div><div class="line"> 4199 deploy    20   0 7128760 1.060g   4276 S   0.3 13.9 527:00.09 java                                                                                                                                          </div><div class="line">    1 root      20   0   60600  22460   1972 S   0.0  0.3  28:32.82 systemd                                                                                                                                       </div><div class="line">    2 root      20   0       0      0      0 S   0.0  0.0   0:06.85 kthreadd                                                                                                                                      </div><div class="line">    3 root      20   0       0      0      0 S   0.0  0.0   5:28.17 ksoftirqd/0                                                                                                                                   </div><div class="line">    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H</div></pre></td></tr></table></figure>
<ul>
<li><p>第一行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">21:33:30    当前系统时间</div><div class="line">up 83 days,6:06     系统运行时间(83天6小时零6分)</div><div class="line">2 users     当前有两个用户登录系统</div><div class="line">load average:n1,n2,n3   系统负载，分别为1分钟，5分钟和15分钟  </div><div class="line"></div><div class="line">## load average数据是每隔5秒钟检查一次活跃的进程数，然后按特定算法计算出的数值。如果这个数除以逻辑CPU的数量，</div><div class="line">结果高于5的时候就表明系统在超负荷运转了</div></pre></td></tr></table></figure>
</li>
<li><p>第二行 <code>进程状态</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">系统当前一共有132个进程，其中运行状态1个，休眠状态131个，stopped状态0个，zombie(僵尸)状态0个</div></pre></td></tr></table></figure>
</li>
<li><p>第三行 <code>CPU状态</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">cpu状态 %Cpu(s):  </div><div class="line">0.6 us  用户空间占用CPU百分比</div><div class="line">0.2 sy  内核空间占用CPU百分比 </div><div class="line">0.0 ni  用户进程空间改变过优先级的进程占用CPU百分比</div><div class="line">98.9 id 空闲CPU百分比</div><div class="line">0.0 wa  等待输入输出（IO）的CPU占比</div><div class="line">0.0 hi  硬中断占用CPU的百分比</div><div class="line">0.0 si  软中断占用CPU百分比</div><div class="line">0.3 st  虚拟机占用百分比</div></pre></td></tr></table></figure>
</li>
<li><p>第四行 <code>内存状态</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">内存状态（单位Kib）</div><div class="line">8010968 total       物理内存总量</div><div class="line">750528 free         空闲内存总量</div><div class="line">4151872 used        使用的物理内存</div><div class="line">3108568 buff/cache  用作缓存的内存</div></pre></td></tr></table></figure>
</li>
<li><p>第五行 <code>swap区状态</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">8388604 total,  8251808 free,   136796 used.  3582444 avail Mem</div></pre></td></tr></table></figure>
</li>
<li><p>第七行 <code>各个进程状态</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">PID     进程id</div><div class="line">USER    进程所有者</div><div class="line">PR      进程优先级</div><div class="line">NI      nice值。负值表示高优先级，正值表示低优先级</div><div class="line">VIRT    进程使用的虚拟内存总量，单位kb。VIRT=SWAP+RES</div><div class="line">RES     进程使用的、未被换出的物理内存大小，单位kb。RES=CODE+DATA</div><div class="line">SHR     共享内存大小，单位kb</div><div class="line">S       进程状态。D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程</div><div class="line">%CPU    上次更新到现在的CPU时间占用百分比</div><div class="line">%MEM    进程使用的物理内存百分比</div><div class="line">TIME+   进程使用的CPU时间总计，单位1/100秒</div><div class="line">COMMAND 进程名称（命令名/命令行）</div></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="常用操作"><a href="#常用操作" class="headerlink" title="常用操作"></a>常用操作</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">top                     //每隔5秒显式所有进程的资源占用情况</div><div class="line">top -d 2                //每隔2秒显式所有进程的资源占用情况</div><div class="line">top -c                  //每隔5秒显式进程的资源占用情况，并显示进程的命令行参数(默认只有进程名)</div><div class="line">top -p 12345 -p 6789    //每隔5秒显示pid是12345和pid是6789的两个进程的资源占用情况</div><div class="line">top -d 2 -c -p 123456   //每隔2秒显示pid是12345的进程的资源使用情况，并显式该进程启动的命令行参数</div><div class="line">top -H -p 123456        //每隔5秒显示pid是12345的进程的各线程资源使用情况</div></pre></td></tr></table></figure>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/06/01/Hello/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/06/01/Hello/" itemprop="url">Hello</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-01T22:16:31+08:00">
                2017-06-01
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/test/" itemprop="url" rel="index">
                    <span itemprop="name">test</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="Test"><a href="#Test" class="headerlink" title="Test"></a>Test</h2><ul>
<li>wokao</li>
<li>wokao<code>test</code> <code>shibushi</code><strong>zhongguo</strong></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> ApplicationContext <span class="title">getApplicationContext</span><span class="params">()</span> </span>&#123;</div><div class="line">    <span class="keyword">return</span> applicationContext;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/06/01/hello-world/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fenlon">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fenlon's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/06/01/hello-world/" itemprop="url">Hello World</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-01T20:56:20+08:00">
                2017-06-01
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Welcome to <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new <span class="string">"My New Post"</span></div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.jpeg"
               alt="Fenlon" />
          <p class="site-author-name" itemprop="name">Fenlon</p>
           
              <p class="site-description motion-element" itemprop="description">Do Something</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">7</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Fenlon</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
    <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
